package com.carrot.newsgallery.service.impl;

import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.carrot.newsgallery.entity.UserInfo;
import com.carrot.newsgallery.mapper.UserInfoMapper;
import com.carrot.newsgallery.service.UserInfoService;
import com.carrot.newsgallery.utils.MyLoginException;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService{

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public void createFavorList(String tableName){
        userInfoMapper.createTable(tableName);
    }

    @Override
    public UserInfo getByUsername(String username) {
        LambdaQueryWrapper<UserInfo> lqw = new LambdaQueryWrapper<>();
        lqw.eq(true,UserInfo::getUsername,username);
        return userInfoMapper.selectOne(lqw);
//        return userInfoMapper.selectCount(lqw) == 1;
    }

    @Override
    public UserInfo getByUuid(String uuid) {
        LambdaQueryWrapper<UserInfo> lqw = new LambdaQueryWrapper<>();
        lqw.eq(true,UserInfo::getUuid,uuid);
        return userInfoMapper.selectOne(lqw);
    }
}
